package es.twentymobile.mule.modules.jpa.strategy;

import javax.persistence.EntityManager;

public class EntityManagerMergeStrategy extends AbstractEntityManagerStrategy {

	public EntityManagerMergeStrategy(EntityManager em, Boolean flush) {
		this.em = em;
		this.flush = flush;
	}

	public <T> T execute(T entity) {
		T result = em.merge(entity);
		if (flush) {
			em.flush();
		}
		return result;
	}

}
